package top.stmo.blog.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.stmo.blog.dao.vo.Result;
import top.stmo.blog.service.CategoryService;

@RestController
@RequestMapping("/categorys")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    @GetMapping
    public Result categorises() {
        return categoryService.findAll();
    }

    @GetMapping("/detail")
    public Result categorisesDetail() {
        return categoryService.findAllDetail();
    }

    /**
     * 分类文章列表
     * @param id
     * @return
     */
    @GetMapping("/detail/{id}")
    public Result categoryDetailById(@PathVariable("id") Long id) {
        return categoryService.categoryDetailById(id);
    }
}
